var adaptive = function() {
	var num = 6; // 第排图片数
	var w = $('#specialList').width() / num;
	$('#specialList li').css({'width': w + 'px'});
	$('#specialList img').css({'width': (w - 38) + 'px'});
	
	// 重新排版
	var h = Array();
	var h1 = Array();
	var pos = Array();
	$('#specialList li').each(function(i){
		var row = Math.floor(i / num);
		var m = i % num;
		var l = m * w;
		var hx = $(this).height();
		if(typeof(h1[m]) == 'undefined') {
			h1[m] = hx;
		} else {
			h1[m] = h1[m] + hx;
		}
		if(row == 0) {
			pos[i] = {left:l + 'px', top: '0px'}
		} else {
			var ti = m * row;
			pos[i] = {left:l + 'px', top: (h1[m] - hx) + 'px'}
		}
	});
	eval('var maxHeight = Math.max(' + h1.join(',') + ');');
	$('#specialList').css({'height': maxHeight + 'px'});
	$('#specialList li').each(function(i){
		var l = pos[i]['left'];
		var t = pos[i]['top'];
		$(this).css({position:'absolute',left:l,top:t});
	});
};
if(window.addEventListener){
	window.addEventListener('load', function(){adaptive();}, false);
}else{
	window.attachEvent('onload', function(){adaptive();});
}
$(window).resize(function(){adaptive();});
